using System;

namespace UwinEducation.Application.Common.Exceptions
{
    /// <summary>
    /// 乐观并发冲突异常
    /// </summary>
    public class ConcurrencyException : Exception
    {
        /// <summary>
        /// 初始化乐观并发冲突异常
        /// </summary>
        /// <param name="entityName">实体名称</param>
        /// <param name="id">实体ID</param>
        public ConcurrencyException(string entityName, object id)
            : base($"数据已被其他用户修改。实体: {entityName}, ID: {id}")
        {
            EntityName = entityName;
            Id = id;
        }

        /// <summary>
        /// 实体名称
        /// </summary>
        public string EntityName { get; }

        /// <summary>
        /// 实体ID
        /// </summary>
        public object Id { get; }
    }
} 